function part = disMin(A,B,car)

%  get the nearest dispart between one point and one line 
% param A ,B : the two dot of A line
% parma P : the point that in the car
% return dispart : the nearest dispart 
%car: []
%

% 输入值 car为车上选出的探测点
% A,B 为 边界点的两端
% 返回值为数组 part【】 长度与car 的长度相同 
% 返回所有探测点对于该线段的最短距离。

a = length(car);
part = ones(1,a(1));

for i = 1:length(car)
    dispart=0;
    P = car(i,:);
    r = (  ( P(1)-A(1) )*( B(1)-A(1) )+ ( P(2)-A(2) )*( B(2)-A(2) )  )/getDis2(A,B);
    if r<=0  
        dispart =sqrt(getDis2(A,P));

    elseif (r>=1)
        dispart =sqrt(getDis2(B,P));
    else 
        ac = r*sqrt(getDis2(B,A));
        dispart = sqrt(getDis2(A,P)-ac^2);
    end
    
    
    if(part(i)>=dispart)
       part(i) = dispart;
    end                                                                                                             


end
